package com.aitemv.web.process;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aitemv.base.BaseEntity;
import com.aitemv.entity.ProcessEntity;
import com.aitemv.services.ProcessService;
import com.aitemv.web.base.BaseAction;
/**
 * @ClassName: ProcessAction 
 * @Description:流程管理的controller 
 * @author java_lyvee@126.com 
 * @date 2014-1-9 下午5:34:00 
 */
@Controller
@RequestMapping(value = "/back/*")
public class ProcessAction extends BaseAction {
	@Autowired
	private ProcessService processService;
	/**
	 * @Title: queryForList 
	 * @Description: 查询返回list
	 * @param request
	 * @param response
	 * @return List<ProcessEntity>
	 */
	@RequestMapping(value = "processList.do")
	public @ResponseBody List<? extends BaseEntity> queryForList(HttpServletRequest request,
			HttpServletResponse response){
		ProcessEntity entity = new ProcessEntity();
		List<? extends BaseEntity> list =  processService.queryForList(entity);
		return list;
		
	}
	
	/**
	 * @Title: addOrUpdate 
	 * @Description: 添加一个流程
	 * @param request
	 * @param response
	 * @return  modelMap
	 * @return Map<String,Object>  返回类型
	 * @throws
	 */
	@RequestMapping(value = "addProcess.do")
	public @ResponseBody Map<String, Object> addOrUpdate(HttpServletRequest request,
			HttpServletResponse response){
		Map<String, Object> modelMap = new HashMap<String, Object>();
		ProcessEntity entity = new ProcessEntity();
		entity.setName(request.getParameter("name"));
		entity.setProcessKey(request.getParameter("processKey"));
		processService.addOrUpdate(entity);
		modelMap.put("success", "true");
		return modelMap;
	}
	@Override
	public String forward(ModelMap model, HttpServletRequest request,
			HttpServletResponse response) {
		return null;
	}

}
